﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace _02_UdpClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Server");

            UdpClient server = new UdpClient(new IPEndPoint(IPAddress.Parse("10.7.5.1"), 12345));

            Console.WriteLine("Server started and wait clients");

            IPEndPoint point = null;
            //IPEndPoint uniPoint = new IPEndPoint(IPAddress.Broadcast, 12345);
            while(true)
            {
                byte [] buffer = server.Receive(ref point);
                Console.WriteLine("{0} : {1}", point.Address, Encoding.ASCII.GetString(buffer));
                server.Send(buffer, buffer.Length, point);
                //server.Send(buffer, buffer.Length, uniPoint);
            }

        }
    }
}
